import Vue from 'vue'
import Router from 'vue-router'
import UserRouter from './user'
import HomeRouter from './home'
import Home from '@/pages/home/Home'
import Author from '@/pages/home/Author'
import Shai from '@/pages/shai/Shai'
import Type from '@/pages/type/Type'
import Cart from '@/pages/cart/Cart'
import Order from '@/pages/cart/Order'
import User from '@/pages/user/User'
import Login from '@/pages/login/Login'
import Register from '@/pages/login/Register'
import Detail from '@/pages/detail/Detail'
import DetailHaowu from '@/pages/detail/DetailHaowu'
import Alipay from '@/pages/cart/Alipay'
import List from '@/pages/list/List'
import ListPoint from '@/pages/list/ListPoint'
import ListHaowu from '@/pages/list/ListHaowu'
import Pet from '@/pages/home/Pet'
import Privacy from '@/pages/home/Privacy'
import IntegralList from '@/pages/list/IntegralList'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [{
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '美麦就好'
    }
  }, {
    path: '/privacy',
    name: 'Privacy',
    component: Privacy,
    meta: {
      title: '隐私政策'
    }
  }, {
    path: '/author',
    name: 'Author',
    component: Author,
    meta: {
      title: '美麦就好'
    }
  }, {
    path: '/type',
    name: 'Type',
    component: Type,
    meta: {
      title: '分类 - 美麦就好'
    }
  }, {
    path: '/shai',
    name: 'Shai',
    component: Shai,
    meta: {
      title: '晒一晒'
    }
  }, {
    path: '/cart',
    name: 'Cart',
    component: Cart,
    meta: {
      requireAuth: true,
      title: '购物车'
    }
  }, {
    path: '/order',
    name: 'Order',
    component: Order,
    meta: {
      title: '确定订单'
    }
  }, {
    path: '/user',
    name: 'User',
    component: User,
    meta: {
      requireAuth: true,
      title: '我的'
    }
  }, {
    path: '/login',
    name: 'Login',
    component: Login,
    meta: {
      title: '登录'
    }
  }, {
    path: '/register',
    name: 'Register',
    component: Register,
    meta: {
      title: '注册'
    }
  }, {
    path: '/detail/:pid',
    name: 'Detail',
    component: Detail,
    meta: {
      title: '产品 - 美麦就好'
    }
  }, {
    path: '/detailHaowu/:pid',
    name: 'DetailHaowu',
    component: DetailHaowu,
    meta: {
      title: '产品'
    }
  }, {
    path: '/list',
    name: 'List',
    component: List,
    meta: {
      title: '列表'
    }
  }, {
    path: '/listpoint',
    name: 'ListPoint',
    component: ListPoint,
    meta: {
      title: '积分列表'
    }
  }, {
    path: '/listhaowu',
    name: 'ListHaowu',
    component: ListHaowu,
    meta: {
      title: '卿点好物列表'
    }
  }, {
    path: '/integralList',
    name: 'IntegralList',
    component: IntegralList,
    meta: {
      title: '列表'
    }
  }, {
    path: '/pet',
    name: 'Pet',
    component: Pet,
    meta: {
      title: '宠物'
    }
  }, {
    path: '/alipay',
    name: 'Alipay',
    component: Alipay,
    meta: {
      title: '支付宝'
    }
  },
  ...HomeRouter,
  ...UserRouter],
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
